from datetime import datetime
from sqlalchemy import Column, Integer, String, DateTime, Date, DECIMAL, CHAR, ForeignKey, Boolean
from sqlalchemy.orm import relationship
from config.database import Base

class EmployeeSocialSecurity(Base):
    """
    员工社保表
    """
    __tablename__ = 'employee_social_security'

    id = Column(Integer, primary_key=True, autoincrement=True, comment='社保ID')
    employee_id = Column(Integer, ForeignKey('employee_info.id'), nullable=False, comment='员工ID')
    is_paying = Column(Boolean, nullable=True, default=False, comment='是否正在缴纳')
    social_security_amount = Column(DECIMAL(10, 2), nullable=True, default=0, comment='社保缴纳金额')
    start_date = Column(Date, nullable=True, comment='开始日期')
    end_date = Column(Date, nullable=True, comment='结束日期')
    del_flag = Column(CHAR(1), nullable=True, default='0', comment='删除标志（0代表存在 2代表删除）')
    create_by = Column(String(64), nullable=True, comment='创建者')
    create_time = Column(DateTime, nullable=True, default=datetime.now(), comment='创建时间')
    update_by = Column(String(64), nullable=True, comment='更新者')
    update_time = Column(DateTime, nullable=True, default=datetime.now(), onupdate=datetime.now, comment='更新时间')

    # 建立与员工表的关联关系
    employee = relationship('EmployeeInfo', backref='social_securities') 